package git.soulbgm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import git.soulbgm.config.SysConfig;
import git.soulbgm.mapper.NetworkEquipmentPortInfoMapper;
import git.soulbgm.pojo.NetworkEquipmentPortInfo;
import git.soulbgm.pojo.NodeInfo;
import git.soulbgm.service.NetworkEquipmentPortInfoService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 网络设备接口信息服务实现
 *
 * @author SoulBGM
 * @date 2023-01-09
 */
@Service
public class NetworkEquipmentPortInfoServiceImpl extends ServiceImpl<NetworkEquipmentPortInfoMapper, NetworkEquipmentPortInfo> implements NetworkEquipmentPortInfoService {

    /**
     * Cacheable
     * value：缓存key的前缀。
     * key：缓存key的后缀。
     * sync：设置如果缓存过期是不是只放一个请求去请求数据库，其他请求阻塞，默认是false。
     */
    @Cacheable(value = "equipmentPortInfoAll", sync = true)
    @Override
    public List<NetworkEquipmentPortInfo> getCacheEquipmentPortInfoAll() {
        return list(new LambdaQueryWrapper<NetworkEquipmentPortInfo>().eq(NetworkEquipmentPortInfo::getRegionCode, SysConfig.getConfig().getRegionCode()));
    }

}
